//
//  ZH_TopUpMoneyTableViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/23.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_TopUpMoneyTableViewCell.h"
@interface ZH_TopUpMoneyTableViewCell()
@property (nonatomic,weak)UILabel *moneyLabel;
@property (nonatomic,weak)UITextField *textField;
@property (nonatomic,weak)UILabel *payLabel;
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UIImageView *payImage;
@property (nonatomic,weak)UILabel *paysLabel;
@property (nonatomic,weak)UIButton *payButton;
@end
@implementation ZH_TopUpMoneyTableViewCell

///创建
+(instancetype)cellWithTableView:(UITableView*)tableView
{
    static NSString *ID = @"ZH_TopUpMoneyTableViewCell";
    ZH_TopUpMoneyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[ZH_TopUpMoneyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
///初始化
-(void)initDefault
{
    [self unShowClickEffect];
    self.bottomShortLineImage.hidden = NO;
}
- (void)loadSubviewConstraints{
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(28));
        make.left.equalTo(self.contentView).offset(FITSCALE(23));
        make.width.mas_equalTo(FITSCALE(71));
    }];
    [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.moneyLabel);
        make.left.equalTo(self.moneyLabel.mas_right).offset(FITSCALE(11));
        make.height.mas_equalTo(FITSCALE(38));
        make.right.equalTo(self.contentView).offset(FITSCALE(-22));
    }];
    [self.payLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.moneyLabel.mas_bottom).offset(FITSCALE(52));
        make.left.equalTo(self.moneyLabel);
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.payLabel.mas_bottom).offset(FITSCALE(5));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.right.equalTo(self.contentView).offset(FITSCALE(-11));
        make.height.mas_equalTo(FITSCALE(1));
    }];
    [self.payImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom).offset(FITSCALE(8));
        make.left.equalTo(self.contentView).offset(FITSCALE(21));
        make.bottom.equalTo(self.contentView).offset(FITSCALE(-9));
    }];
    [self.paysLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.payImage);
        make.left.equalTo(self.payImage.mas_right).offset(FITSCALE(10));
    }];
    [self.payButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom);
        make.left.right.bottom.equalTo(self.contentView);
    }];
}
///输入框 回调 方法
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    //    if(self.onEnterTextFieldBlock){
    //        self.onEnterTextFieldBlock(textField.text, textField.tag);
    //    }
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.textField endEditing:YES];
    return YES;
}

#pragma mark - getter,setter
- (UILabel *)moneyLabel{
    if (!_moneyLabel) {
        UILabel *label = [UILabel createLabelWithText:@"充值金额:" font:kFontSize_28];
        [self.contentView addSubview:_moneyLabel = label];
    }
    return _moneyLabel;
}
- (UITextField *)textField
{
    if(!_textField){
        UITextField *textField = [UITextField createTextFieldWithPlaceholder:@" 请输入金额" placeholderColor:kFontColorGray delegateTarget:self];
        textField.borderStyle = UITextBorderStyleNone;
        textField.font = kFontSize_28;
        textField.textAlignment = NSTextAlignmentLeft;
        textField.returnKeyType = UIReturnKeyDone;
        [textField setTextColor:kFontColorBlack];
        textField.layer.cornerRadius = FITSCALE(3);
        textField.layer.borderWidth = FITSCALE(1);
        textField.layer.borderColor = [UIColor colorWithHexString:@"#CCCCCC"].CGColor;
        textField.layer.masksToBounds = YES;
        textField.clipsToBounds = YES;
        [self.contentView addSubview:_textField = textField];
    }
    return _textField;
}
- (UILabel *)payLabel{
    if (!_payLabel) {
        UILabel *label = [UILabel createLabelWithText:@"支付方式:" font:kFontSize_30];
        [self.contentView addSubview:_payLabel = label];
    }
    return _payLabel;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_lineView = view];
    }
    return _lineView;
}
- (UIImageView *)payImage{
    if (!_payImage) {
        UIImageView *image = [UIImageView createImageViewWithName:@"icon_zfbpay"];
        [self.contentView addSubview:_payImage = image];
    }
    return _payImage;
}
- (UILabel *)paysLabel{
    if (!_paysLabel) {
        UILabel *label = [UILabel createLabelWithText:@"支付宝" font:kFontSize_30];
        [self.contentView addSubview:_paysLabel = label];
    }
    return _paysLabel;
}
- (UIButton *)payButton{
    if (!_payButton) {
        UIButton *button = [UIButton createNoBgButtonWithTitle:@"" target:self action:nil];
        button.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_payButton = button];
    }
    return _payButton;
}
@end
